package com.woniuxy.controller;

import com.woniuxy.entity.dto.operations.CardAddDTO;
import com.woniuxy.entity.dto.operations.CardDisplayDTO;
import com.woniuxy.service.CardService;
import com.woniuxy.util.CodeUtil;
import com.woniuxy.util.PageParam;
import com.woniuxy.util.ResponseData;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @BelongsProject: charging-management-platform
 * @BelongsPackage: com.woniuxy.controller
 * @Author: Quan
 * @Date: 2025/3/28 11:41
 */
@RestController
@RequestMapping("/card")
@AllArgsConstructor
public class CardController {
	private CardService cardService;
	private CodeUtil codeUtil;

	/**
	 * @Description: 查询全部充电卡
	 * @Param: []
	 * @return: com.woniuxy.util.ResponseData<?>
	 * @Author: Quan
	 * @Date: 2025/3/28
	 */
	@PostMapping("/queryAll")
	public ResponseData<?> queryAll(@RequestBody PageParam<CardDisplayDTO> pageParam) {
		return cardService.queryAll(pageParam);
	}

	/**
	 * @Description: 查询所有的会员类型
	 * @Param: []
	 * @return: com.woniuxy.util.ResponseData<?>
	 * @Author: Quan
	 * @Date: 2025/3/29
	 */
	@GetMapping("/queryAllMembershipLevel")
	public ResponseData<?> queryAllMembershipLevel() {
		return cardService.queryAllMembershipLevel();
	}

	/**
	 * @Description: 通过id对对应的card进行逻辑删
	 * @Param: [id]
	 * @return: com.woniuxy.util.ResponseData<?>
	 * @Author: Quan
	 * @Date: 2025/3/30
	 */
	@GetMapping("/delCardById/{id}")
	public ResponseData<?> delCardById(@PathVariable("id") Long id) {
		return cardService.delCardById(id);
	}

	/**
	 * @Description: 通过对应的id修改对应状态
	 * @Param: [id]
	 * @return: com.woniuxy.util.ResponseData<?>
	 * @Author: Quan
	 * @Date: 2025/3/30
	 */
	@GetMapping("/forbiddenById/{id}")
	public ResponseData<?> forbiddenById(@PathVariable("id") Long id) {
		return cardService.forbiddenById(id);
	}

	/**
	 * @Description: 添加充电卡进来
	 * @Param: [cardDisplayDTO]
	 * @return: com.woniuxy.util.ResponseData<?>
	 * @Author: Quan
	 * @Date: 2025/3/31
	 */
	@PostMapping("/addCard")
	public ResponseData<?> addCard(@RequestBody CardAddDTO cardAddDTO) {
		return cardService.addCard(cardAddDTO);
	}

	/** 
	 * @Description: 获取编码
	 * @Param: []
	 * @return: com.woniuxy.util.ResponseData<?>
	 * @Author: Quan
	 * @Date: 2025/3/31
	 */
	@GetMapping("/getCode")
	public ResponseData<?> getCode() {
		return ResponseData.ok(codeUtil.generateRegularCode("CARD"));
	}

	/** 
	 * @Description: 通过id对card进行查询
	 * @Param: [id]
	 * @return: com.woniuxy.util.ResponseData<?>
	 * @Author: Quan
	 * @Date: 2025/3/31
	 */
	@GetMapping("/getCardById/{id}")
	public ResponseData<?> getCardById(@PathVariable("id") Long id) {
		return cardService.getCardById(id);
	}

	/**
	 * @Description: 批量进行删除
	 * @Param: [displayDTOs]
	 * @return: com.woniuxy.util.ResponseData<?>
	 * @Author: Quan
	 * @Date: 2025/3/31
	 */
	@PostMapping("/BatchDelCard")
	public ResponseData<?> BatchDelCard(@RequestBody List<CardDisplayDTO> displayDTOs){
		return cardService.BatchDelCard(displayDTOs);
	}

}
